home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15523 < prev    next >
Encoding:
Text File  |  1996-08-05  |  3.5 KB  |  95 lines

  1. Path: news.ahc.ameritech.com!datalytics!usenet
  2. From: Rob Stewart <stew@datalytics.com>
  3. Newsgroups: comp.lang.c++,rec.games.programmer,alt.msdos.programmer,comp.programming
  4. Subject: Re: Young programmers read me.
  5. Date: Fri, 05 Apr 1996 18:32:36 -0500
  6. Organization: Datalytics, Inc
  7. Message-ID: <3165AD94.6F3A@datalytics.com>
  8. References: <4icpp9$7hr@barad-dur.nas.com> <4imqe4$cj3@ping1.ping.be> <1996Mar23.224853.116513@kuhub.cc.ukans.edu> <4j52hn$ikb@news.ios.com> <Pine.OSF.3.91.960403112207.17337H-100000@bud.cc.swin.edu.au> <aidan-0404961557290001@meathook.intac.com>
  9. NNTP-Posting-Host: 204.62.224.71
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (WinNT; I)
  14.  
  15. Aidan Cully wrote:
  16. > In article <Pine.OSF.3.91.960403112207.17337H-100000@bud.cc.swin.edu.au>,
  17. > John Joseph Newbigin <079519@bud.cc.swin.edu.au> wrote:
  18. > > I startted programming in BASIC.  Once I realised this was not a "real"
  19. > > language I started using Pascal.  Once I realised Pascal sucks, I started
  20. > > using C(++).  Now I would rather use BASIC than Pascal.  That must mean
  21. > > BASIC is not dieing either?
  22. > >  Newbs
  23. >    C++ is an incredibly ugly language with some of the worst looking
  24. > constructs I have ever seen(e.g., -> to dereference a pointer to a record?
  25. > what about a handle? the way this is done is incredibly ugly and more than
  26. > a little unreadable), and a really very counterintuitive #define block.
  27. > If C were really a free form language, then the #define directive could
  28. > not be used as it assumes certain things about syntax (i.e. rest of the
  29. > line is to be used *only* for the #define block).  
  30.  
  31. #define is a preprocessor macro and is not part of C.
  32.  
  33. > Add to this that C++
  34. > does not follow one of the guiding principles of OOP (i.e. hiding the
  35. > implementation from the user) by allowing people to see the private and
  36. > protected members of classes, 
  37.  
  38. There is a simple means of doing this:
  39.  
  40. header:
  41.  
  42. class X
  43. {
  44.    private:
  45.       struct XRep;
  46.  
  47.       XRep* m_pRep;
  48. };
  49.  
  50. implementation:
  51.  
  52. struct X::XRep
  53. {
  54.    // declare data members here
  55. };
  56.  
  57. Now, all member functions of X access X's data members through 
  58. m_pRep.  Since XRep's declaration is only in the implementation 
  59. file (typically a .C or .cpp file), you can change it at will 
  60. with no effect on X's declaration.
  61.  
  62. Of course, you get performance losses with such a compilation 
  63. firewall.  That is, every data member access is done by 
  64. dereferencing a pointer, and all public and protected member 
  65. functions must not be inline.  Once you do these things, you 
  66. lose some of that performance advantage C++ offers.
  67.  
  68. > and I see one of the ugliest languages
  69. > developed.
  70.  
  71. [snip]
  72.  
  73. >    I also think that speed is essential for most commercial applications,
  74. > and this alone is what makes C/C++ a widely used Commercial application,
  75. > but I get upset when people confuse "popular" with "good."  I'm writing a
  76. > game in C++ right now because the speed is so good, but just as a
  77. > programming language, it really blows.
  78.  
  79. There are idioms and patterns for most things you want to do 
  80. with C++ that alleviate much of what bothers you about the 
  81. language and that reduce errors and performance problems.  You 
  82. simply have to do a little reading and research to learn about 
  83. them.
  84.  
  85. You may not like the symbols used in C++, but I like the code 
  86. compression they provide.  Typing '{' is much faster than typing 
  87. 'BEGIN.'  Readability is subjective; Greek is not readable until 
  88. you know the language.
  89.  
  90. -- 
  91. Robert Stewart        | My opinions are usually my own.
  92. Datalytics, Inc.    | stew@datalytics.com
  93.